package com.base.social.auth.factory;

import com.base.social.auth.request.AuthWeChatMp;
import com.base.social.cache.AuthStateCache;
import com.base.social.config.AuthConfig;
import com.base.social.auth.Auth;
import com.base.social.auth.AuthFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

public class WechatMpAuthFactory implements AuthFactory {

//    /**
//     * 客户端id：对应各平台的appKey
//     */
//    private String clientId;
//
//    /**
//     * 客户端Secret：对应各平台的appSecret
//     */
//    private String clientSecret;
//
//    /**
//     * 登录成功后的回调地址
//     */
//    private String redirectUri;
//
//    /**
//     * 微信响应类型 默认code
//     */
//    private String responseType;
//
//    /**
//     * 微信授权作用域
//     */
//    private String scope;

    private static class Holder{
        private static final WechatMpAuthFactory INSTANCE = new WechatMpAuthFactory();
    }

    //实例化
    public static WechatMpAuthFactory build(){
        return Holder.INSTANCE;
    }

    @Override
    public Auth instance(AuthConfig authConfig, AuthStateCache authStateCache) {
        if (authStateCache != null) {
            return new AuthWeChatMp(authConfig, authStateCache);
        }
        return new AuthWeChatMp(authConfig);
    }

}
